import requests
class IHRMEMP:

# 封装员工管理接口
    @classmethod
    def add_emp(cls,token,body):
        # 添加员工
        url='http://ihrm2-test.itheima.net/api/sys/user'
        headers = {"Content-Type": "application/json", "Authorization": token}

        resp = requests.post(url=url, headers=headers, json=body)
        return resp

    @classmethod
    def query_emp(cls,emp_id,token):
        # 查询员工
        url1 = 'http://ihrm2-test.itheima.net/api/sys/user/'+emp_id
        headers1 = {"Authorization": token}
        resp1 = requests.get(url=url1, headers=headers1)
        return resp1

    @classmethod
    def aa_emp(cls,emp_id1,token,body2):
        # 修改员工
        url2 = 'http://ihrm2-test.itheima.net/api/sys/user/'+emp_id1
        headers2 = {"Content-Type": "application/json", "Authorization": token}

        resp2 = requests.put(url=url2, headers=headers2, json=body2)
        return resp2

    @classmethod
    def delete_emp(cls,emp_id2,token):
        # 删除员工
        url3 = 'http://ihrm2-test.itheima.net/api/sys/user/'+emp_id2
        headers3 = {"Authorization": token}
        resp3 = requests.delete(url=url3, headers=headers3)
        return resp3

